import React from 'react';
import {connect} from 'react-redux'
import { bindActionCreators } from 'redux'
import * as userinfoActions from '../actions/userinfo'
class Logon extends React.Component{
    render(){
        return (
            <div className="container-fluid">
                <div className="form-group">
                    <input type="text" value={this.props.userinfo.userid} className="form-control"/>
                </div>
                <div className="form-group">
                    <button className="btn btn-block btn-success">action</button>
                </div>
            </div>
        )
    }
    componentDidMount() {
        // 模拟登陆
        this.props.userinfoActions.updateuserinfo({
            userid: 'abc'
        })
    }
}

function mapStateToProps(state) {
    return {
        userinfo: state.userinfo
    }
}

function mapDispatchToProps(dispatch) {
    return {
        userinfoActions: bindActionCreators(userinfoActions, dispatch)
    }
}

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Logon)